Repository navigation
fix(libc): end the process without detach routines in _Exit on Windows - #2612
Merged
Merged
Conversation
On Windows std::_Exit ends in ExitProcess, which still runs every module's DLL_PROCESS_DETACH and TLS callbacks after the other threads are gone. A static destructor that joins a worker then waits forever: a title that calls _Exit while libSceVideoOut's flip queue runs (ps5-opengl's retirement fail-stop) stays alive in FlipQueue's destructor. _Exit and libkernel's _exit now terminate the process with TerminateProcess, as _exit ends a POSIX process: no atexit handlers, stream flushes or module destructors.
9 tasks done
Collaborator
|
Checked the diff ( |
9 tasks done
11 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carrying @AlxcBTW's fix for #2579 while PR intake is paused. The change is theirs (from
AlxcBTW/AnyPS5:fix/windows-immediate-exit, 2feef9e).What
_Exit(libc) and_exit(libkernel) end the process throughLibcTerminate_nid_no_patch, which callsTerminateProcesson Windows andstd::_Exitelsewhere.Why
On Windows
std::_Exitends inExitProcess, which still runs every module'sDLL_PROCESS_DETACHand its TLS and FLS callbacks after the other threads are gone.FlipQueue's destructor then joins a thread that no longer exists and waits forever. Homebrew UI Lab (PPSA99050) calls_Exit(EXIT_FAILURE)afterand the process stays alive, with one thread in
std::_Sp_counted_ptr_inplace<FlipQueue>::_M_dispose(libSceVideoOut.prx) waiting instd::thread::join. POSIX_exitruns no atexit handlers, stream flushes or module destructors.Tested
mainc72d5ce passes on Linux, macOS and Windows.guest_immediate_exitnow also registers an FLS callback that would end the process with 4. It exits with 4 without the change and 0 with it.ctest -R "kill|exit|process|shutdown|atexit|libc|kernel": 19/19.EXIT_FAILURE) instead of staying alive.tools/check_conventions.pypasses, and the branch merges cleanly with currentmain.Fixes #2579
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)